package com.ionehe.group.common.zzd.config.base;


public enum SubSystem {
    sys_portal_site,
    sys_directory,
    sys_noncode,
    sys_codeless,
    sys_component_center,
    sys_console;


    public static SubSystem getEntityByValue(String value) {
        if (value == null) {
            return null;
        }
        for (SubSystem entity : values()) {
            if (entity.toString().equals(value)) {
                return entity;
            }
        }
        return null;
    }

    public static String getZhNameByValue(SubSystem subSystem) {
        if (subSystem == null) {
            return null;
        }
        switch (subSystem) {
            case sys_directory:
                return "目录管理子系统";
            case sys_codeless:
                return "低代码平台";
            case sys_portal_site:
                return "门户子系统";
            case sys_component_center:
                return "组件服务中心";
            case sys_console:
                return "控制台";
        }
        return "未注册的测试系统";
    }


    public static String getZhNameByName(String value) {
        if (value == null) {
            return null;
        }
        for (SubSystem entity : values()) {
            if (entity.toString().equals(value)) {
                return getZhNameByValue(entity);
            }
        }
        return null;
    }

    public static String getSubsystemNameFromSystemAlias(String systemAlias) {
        for (SubSystem subSystem : values()) {
            if (systemAlias.contains(subSystem.toString())) {
                return subSystem.toString();
            }
        }
        return null;
    }


    public static boolean isComponent(String systemAlias) {
        if (systemAlias != null && systemAlias.length() > 0 && systemAlias.startsWith("component_")) {
            return true;
        }
        return false;
    }
}


